package sanrenxing.dayEnd.backRepertoryTotal.dao;


import org.apache.ibatis.annotations.*;
import sanrenxing.dayEnd.backRepertoryTotal.domain.ExchangeVarietyRate;

import java.util.List;
import java.util.Map;

/**
 * 交易品种费率表
 */
public interface ExchangeVarietyRateDao {
    /**
     * 将基金实体添加数据库基金表中
     * @param exchangeVarietyRate 基金对象
     * @return 0:添加失败,1:添加成功
     */
    @Insert("insert into exchangeVarietyRate values(seqExchangeVarietyRate.nextval,#{noeName},#{tradeVar},#{staDuty},#{tranFee},#{collFee},#{handFee})")
    public int add(ExchangeVarietyRate exchangeVarietyRate);
    /**
     * 从表中根据基金编号删除一行数据
     * @param BreedRateId 基金编号
     * @return 删除影响的行数(0:删除失败,1:删除成功)
     */
    @Delete("delete from exchangeVarietyRate where BreedRateId=#{BreedRateId}")
    public int delete(@Param("BreedRateId") String BreedRateId);
    /**
     * 修改数据到foundation表
     * @param exchangeVarietyRate 员工对象
     * @return 0:修改失败,1:修改成功
     */
    @Update("update exchangeVarietyRate set noeName=#{noeName},tradeVar=#{tradeVar},staDuty=#{staDuty},tranFee=#{tranFee},collFee=#{collFee},handFee=#{handFee}" +
            " where BreedRateId=#{BreedRateId}")
    public int update(ExchangeVarietyRate exchangeVarietyRate);

    @Select("<script>" +
            "select * from " +
            " (select rownum rn,exchangeVarietyRate.* from exchangeVarietyRate " +
            " <where>#{end}>=rownum</where>)" +
            "<where>" +
            "<if test='exchangeVarietyRate.noeName!=null'>" +
            " and noeName like '%${exchangeVarietyRate.noeName}%'" +
            "</if>" +
            "<if test='exchangeVarietyRate.tradeVar!=0'>" +
            " and tradeVar=#{exchangeVarietyRate.tradeVar}" +
            "</if>" +
            " and rn>=#{start}" +
            "</where>" +
            "</script>")
    @Results({
            @Result(property = "BreedRateId",column = "BreedRateId"),
            @Result(property = "noeName",column = "noeName"),
            @Result(property = "tradeVar",column = "tradeVar"),
            @Result(property = "staDuty",column = "staDuty"),
            @Result(property = "tranFee",column = "tranFee"),
            @Result(property = "collFee",column = "collFee"),
            @Result(property = "handFee",column = "handFee")
    })
    public List<ExchangeVarietyRate> queryAll(Map<String, Object> map);
    /**
     * 统计记录数
     * @param
     * @return 记录行数据
     */
    @Select("select count(*) from exchangeVarietyRate")
    public int count();

}
